<template>
	<view class="container padding-top-sm position-relative">
		<view class="bg-to-right padding flex justify-start align-center margin-left-sm margin-right-sm radius10">
			<image :src="userInfo.userIcon" mode="" class="cu-avatar round lg"></image>
			<view class="text-white margin-left">
				<view class="text-15 text-bold">
					{{userInfo.nickname}}
				</view>
				<view class="text-sm margin-top-xs">
					注册时间：{{userInfo.createTime}}
				</view>
			</view>
		</view>
		<view class="radius10 padding margin-left-sm margin-right-sm margin-top margin-bottom bg-white">
			<view class="flex justify-between align-center">
				<view class="flex justify-start align-center">
					<image class="p-img" :src="baseUrl + '/static/Promote4.png'" mode=""></image>
					<view class="text-15 text-bold text-333 margin-left-sm">
						推广关系 ({{total}})
					</view>
				</view>
				<view class="flex justify-start align-center text-999">
					<view class="text-sm" @click="toPage('/filePage/pages/recomend-list/recomend-list')">
						查看更多
					</view>
					<view class="cuIcon-right margin-left-xs">

					</view>
				</view>
			</view>
			<view class="flex justify-between align-center margin-top" v-for="item in list">
				<view class="flex justify-start align-center">
					<image :src="item.extendUserIcon" mode="" class="cu-avatar round lg"></image>
					<view class="margin-left-sm">
						<view class="text-13 text-333">
							{{item.extendUserName}}（ID:{{item.userId}}）
						</view>
						<view class="text-11 text-999 margin-top-xs">
							注册时间{{item.createTime}}
						</view>
					</view>
				</view>
				<view class="text-sm text-999">
					{{item.userOperatorStatus?'运营商':item.userProviderStatus?'服务商':item.userCourierStatus?'配送工':item.userMechanicStatus?'技工':'暂无'}}
				</view>
			</view>
		</view>
		<view class="height100">

		</view>
		<view class="text-15 text-bold color p-fooder flex justify-center align-center bg-white"
			@click="modalName=true">
			去推广
		</view>
		<view class="cu-modal bottom-modal" :class="modalName?'show':''" @click="hideModal">
			<view class="cu-dialog bg-white" @click.stop="">
				<view class="text-df text-999 padding-sm">
					分享至
				</view>
				<view class="padding-xl flex justify-around align-center">
					<view class="flex justify-center align-center flex-direction">
						
						<!--  #ifdef  MP-WEIXIN-->
						<button open-type="share" style="background-color: initial;">
							<image :src="baseUrl + '/static/wechat.png'" mode=""></image>
							<view class="text-333 text-sm margin-top-xs">
						
								微信好友
							</view>
						</button>
						<!--  #endif -->
						
						<!--  #ifdef  APP-PLUS-->
						<button  @click="tapShare"  style="background-color: initial;">
							<image :src="baseUrl + '/static/wechat.png'" mode=""></image>
							<view class="text-333 text-sm margin-top-xs">
						
								微信好友
							</view>
						</button>
						<!--  #endif -->
						

					</view>
					<view class="flex justify-center align-center flex-direction"
						@click="toPage('/filePage/pages/common-tools/poster/poster')">
						<image :src="baseUrl + '/static/poster.png'" mode=""></image>
						<view class="text-333 text-sm margin-top-xs">
							生成分享海报
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				baseUrl: this.$config.baseUrl,
				modalName: false,
				list: [],
				total: 0,
				userInfo:uni.getStorageSync('userInfo')
			};
		},
		onLoad() {
			this.getList()
			// this.getMyCode()
		},
		methods: {
		
			showModal() {
				this.modalName = true
			},
			hideModal() {
				this.modalName = false
			},
			toPage(url) {
				this.$util.openNewPage(url)
			},
			async getList() {
				const data = {
					extendUserId: uni.getStorageSync('userId'),
					pageSize: 4,
					pageNum: 1
				}
				const [err, rs] = await this.$get(this.$api.recomList, data)
				if (rs) {
					this.list = rs.data.list
				    this.total = rs.data.total
				}
			},
			onShareAppMessage(res) {
				 let code = uni.getStorageSync('userInfo').recommendCode
				return {
					title: `佐佑帮小程序`,
					path: `/pages/file/file?scene=${uni.getStorageSync('userInfo').recommendCode}`,
					
				}
			},
			tapShare(e) {
				e.stopPropagation();
				uni.share({
					provider: 'weixin',
					scene: "WXSceneSession",
					type: 5,
					imageUrl: '/static/default.png',
					title: '佐佑帮小程序',
					miniProgram: {
						id: 'gh_ee4f5c078afc',
						path: `/pages/home/home?scene=${uni.getStorageSync('userInfo').recommendCode}`,
						type: 0,
						webUrl: 'http://uniapp.dcloud.io'
					},
					success: ret => {
						console.log(JSON.stringify(ret));
						this.getforward()
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.p-img {
		width: 40rpx;
		height: 32rpx;
	}

	.p-fooder {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		height: 100rpx;
	}

	.cu-dialog {
		image {
			width: 100rpx;
			height: 100rpx;
		}
	}
</style>
